import request from "@/api/request.js"
import {usetokenstore} from "@/store/token.js";

export const insertAddressService=(addressData)=>{
    const params = new URLSearchParams()
    for (let key in addressData){
        params.append(key,addressData[key])
    }
    const tokenstore=usetokenstore();

    return request.post("/address//addAddress",params,{headers:{'jwt':tokenstore.token}})
}

export const selectAddressDetailService=()=>{
    const tokenstore=usetokenstore();
    return request.post("/address/selectAddressDetail",null,{headers:{'jwt':tokenstore.token}})
}

export const deleteAddressService = (id)=>{
    const params = new URLSearchParams()
    params.append("addressId",id)
    const tokenstore=usetokenstore();

    return request.post("/address/deleteAddress",params,{headers:{'jwt':tokenstore.token}})
}

export const updateAddressService=(updateData)=>{
    const params = new URLSearchParams()
    for (let key in updateData){
        params.append(key,updateData[key])
    }
    const tokenstore=usetokenstore();

    return request.post("/address/updateAddress",params,{headers:{'jwt':tokenstore.token}})

}